package April._17.work4;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        FileOutputStream outA = new FileOutputStream("fileTest\\a.txt",true);
        int count = 0;
        int sum = 0;
        byte[] bytes = new byte[1024];
        FileInputStream inA = null;

        try {
            inA = new FileInputStream("fileTest\\a.txt");
            int read;
            while ((read = inA.read(bytes)) != -1) {
                for (int i = 0; i < read; i++) {
                    if (bytes[i] % 2 == 0) {
                        count++;
                    } else {
                        sum++;
                    }
                }
            }
        } finally {
            if (inA != null) {
                inA.close();
            }
        }

        String s = "偶数个数：" + count;
        String s1 = "奇数个数：" + sum;

        outA.write("\r\n".getBytes());
        outA.write(s.getBytes());
        outA.write("\r\n".getBytes());
        outA.write(s1.getBytes());

        outA.close();

    }
}
